﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using University.Workshop.Business;

namespace University.Workshop.Presenters.IncomeMoney.Search
{
    public class PresenterSearchIncome
    {
        ISearchIncomeView view;

        public PresenterSearchIncome(ISearchIncomeView view)
        {
            this.view = view;
        }

        public void SearchInIncome()
        {
            try
            {
                decimal money = 0;
                view.JournalEntriesFinded = ManagerCollectControl.SearchIncomeByDates(view.InitialDate, view.EndDate, ref money);
                view.TotalMoney = money;
            }
            catch(Exception ex)
            {
                view.JournalEntriesFinded = null;
                view.NotifyErrorMessage(ex.Message);
            }
        }

        public void SendToRead(Model.CollectControl collect)
        {
            if (collect is Model.WaterCollectControl)
                view.NavigateToRead((Model.WaterCollectControl)collect);

            if (collect is Model.OtherCollectControl)
                view.NavigateToRead((Model.OtherCollectControl)collect);

            if (collect is Model.FineCollectControl)
                view.NavigateToRead((Model.FineCollectControl)collect);
        }
    }
}
